package com.hbue.water.controller;

import com.github.pagehelper.PageInfo;
import com.hbue.water.common.CommonResult;
import com.hbue.water.common.ResponseCode;
import com.hbue.water.entity.WaterDetails;
import com.hbue.water.service.WaterDetailsService;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author yushu
 * @date 2021/12/27
 * @apiNate
 */
@RestController
@RequestMapping("/stat")
@Slf4j
@ApiModel("送水详细信息管理Controller")
public class WaterDetailsController {

    @Autowired
    private WaterDetailsService waterDetailsService;

    @ApiOperation("分页查询所有统计送水详细信息")
    @GetMapping("/listWaterPage/{pageNum}/{pageSize}")
    public CommonResult<PageInfo> listWater(
            @ApiParam(name="pageNum",value="当前页",required = true)
            @PathVariable("pageNum") Integer pageNum,
            @ApiParam(name = "pageSize", value = "每页数据量", required = true)
            @PathVariable("pageSize") Integer pageSize){
        PageInfo<WaterDetails> waterDetailsPageInfo = waterDetailsService.listWater(pageNum, pageSize);
        return new CommonResult<>(ResponseCode.RESPONSE_SUCCESS, "ok", waterDetailsPageInfo);
    }

    @ApiOperation("统计送水详细信息")
    @GetMapping("/statWaterDetails")
    public CommonResult<List<WaterDetails>> statWaterDetails(){
        List<WaterDetails> waterList = waterDetailsService.querySendWaterDetails();
        return new CommonResult<>(ResponseCode.RESPONSE_SUCCESS, "ok", waterList);
    }

}
